package com.bank.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

import com.bank.common.Result;
import com.bank.entity.CardInfo;
import com.bank.mapper.CardInfoMapper;

@RestController
@RequestMapping("/api/auth")
public class LoginController {
    @Autowired
    private CardInfoMapper cardInfoMapper;

    @PostMapping("/login")
    public Result<?> login(@RequestBody Map<String, String> params) {
        String cardID = params.get("cardID");
        String pass = params.get("pass");
        CardInfo card = cardInfoMapper.findById(cardID);
        if (card != null && card.getPass().equals(pass)) {
            return Result.success(card);
        }
        return Result.error("卡号或密码错误");
    }
}